1. Field of the Disclosure
The present disclosure relates generally to stack management in a Real-Time Operating Systems (RTOS), and more particularly, to a method and system for reducing memory consumption in an RTOS-based system.
2. Description of the Related Art
An embedded RTOS-based system uses multiple tasks that are each associated with a stack as shown in FIG. 1. When there are a large number of tasks in a system, memory usage of the stack may be considerable. When a new task is added/created in the system, the memory requirements change as memory for the new task is allocated to the stack, which causes Random Access Memory (RAM) requirements to increase.
The following two cases are examples of possible stack usage in a system:
a. The allocated stack size for a particular task is set to a highest possible stack limit, even though the full allocated stack size is not necessarily always utilized by the particular task.
b. At any point of time, one task can be in a running state, while some other tasks may be in a ready (i.e., pre-empted) state, and all remaining tasks are in a suspended (i.e., waiting for an event/message) state.
In the above cases, the allocated stack memory for each task is not necessarily completely utilized at any given point in time. In a traditional RTOS, every task is expected to have a different stack area, and therefore, memory optimizations for stack usage are not possible. Even though certain operating systems apply a stack area reuse concept, it is difficult to apply stack reuse to a resource constraint low cost Machine-Type Communications (MTC) device. In some cases, stack memory can be reused when the task has existed for a certain period, and such a task might be deleted after execution of a specific task. But in a typical MTC device, tasks are created during boot-up time, and remain throughout the life of execution of the MTC device.
In a low-cost System on a Chip (SoC), such as one deployed in MTC devices, in order to bring down the cost of such chips, there is a need for a reduction in memory requirements, so that the MTC devices can function with a lower RAM configurations.
In view of the foregoing, there is a need for an effective scheme in an RTOS scheduler that lowers a memory footprint for task stack usage, allows RAM reduction on a task stack basis, while reducing the overall cost of devices.